import EventDispatch from "@/event/EventDispatch.ts";
import type {EventData, EventType} from "@/event/index";

/**
 * 全局事件总线, 事件发布者类
 */
export default class EventPublisher{
    public static dispatch: EventDispatch = EventDispatch.getInstance();


    /**
     * 全局事件发布方法
     * @param eventType 发布的事件类型
     * @param data 发布的事件数据
     * @param publisher 发布者标识
     * @param ack 事件处理成功的确认方法
     */
    public static publish(eventType: EventType, data: EventData<EventType>, publisher: string, ack: (success: boolean) => void){
        this.dispatch.eventDispatch(eventType, data, publisher, ack);
    }
}